<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!doctype html>
<html>
<head>
<title>里程管理</title>
<%@ include file="../../common/base.jsp" %>
</head>

<body id="body">
<!--head-->
<div id="head">
	<%@ include file="../../common/head.jsp" %>
</div>
<!--head end-->
<!--container-->
<div id="container">
	<div id="pageId" style="display: none;">05-05</div>
		<!--sidebar-->
		<%@ include file="../../common/menu.jsp" %>
	    <!--sidebar-->
    <!--main-->
    <div class="main">
    	<div class="location" style="background-position:22px -109px;">
        	平台管理<span>&gt;</span>里程管理
        </div>
        <!--content-->
        <div class="content">
			<div class="set_buttons">
				<button type="button" class="btn btn_add" onclick="addSubmit()">添加</button>
			</div>
            <div id="tableResult">
            	<table class="table_type1">
	                <thead>
	                    <tr>
	                        <th>序号</th>
	                        <th>里程最小值</th>
							<th>里程最大值</th>
							<th>创建时间</th>
	                        <th>操作</th>
	                    </tr>
	                </thead>
	                <tbody id="bodyResult"></tbody>
	            </table>
            </div>
            <div class="page">
                	<div class="itemNum" >
		                    	显示：<select id="selItem">
		                    			<option selected="selected" id="20">20</option>
		                    			<option id="30">30</option>
		                    			<option id="40">40</option>
		                    			<option id="50">50</option>
		                    		</select>条，共 <a id="totalCount" onclick="javascript:void(0);" ></a> 条
		            </div>
                    <ul class="pagination" id="pageCur"></ul>
            </div>
        </div>
        <!--content-->
        <!--foot-->
		<%@ include file="../../common/foot.jsp" %>
        <!--foot-->
    </div>
    <!--main-->
</div>
<!--container-->
<script src="${pageContext.request.contextPath}/static/js/basic.js"></script>
<script type="text/javascript">

//加载ajax请求
function loadResult(page,numPerPage){
	loadResultPerfect(page,numPerPage,"mileage/queryMileageDate",null);
}

// 加载ajax返回结果
function loadTableResult(data){
	var jo = data.json;
	if(jo != '' && jo != null){
		for (var i = 0; i < jo.length; i++) {
			var content = "<tr>"+
	                    	"<td>"+(i+1)+"</td>" +
							"<td>"+jo[i].minMileage+"</td>" +
							"<td>"+jo[i].maxMileage+"</td>" +
							"<td>"+dateFormatTimeLong(jo[i].createTime)+"</td>" +
	                    	"<td><a href='mileage/showUpdateMileage?id="+jo[i].id+
                				"'>修改</a>&nbsp;<a href='javascript:del("+jo[i].id+");'>删除</a></td>"+
	                      "</tr>";
	        $("#bodyResult").append(content);
	    }
	}
}

function del(id){
    prompt.confirm("您确定要删除该里程信息吗?",function(){
        $.ajax({
            type: "POST",
            url: "${pageContext.request.contextPath}/mileage/deleteMileage",
            dataType:"json",
            data: {
                id:id
            },
            success: function(data){
                prompt.alert(data.msg);
                if (data.errorCode==0) {
                    loadResult(1,$("#selItem").val());
                }
            }
        });
    });
}



function addSubmit(){
	window.location.href = "${pageContext.request.contextPath}/mileage/showAddMileage";
}


//表格排序表头样式
$(document).ready(function(e) {
	loadResult(1,$("#selItem").val());
});

</script>
</body>
</html>